<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDealBuyersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('deal_buyers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->comment('购买用户id=user.id');
            $table->integer('deal_id')->comment('挂卖ID');
            $table->decimal('price','16','4')->comment('单价');
            $table->integer('total_amount')->default('0')->comment('购买数量');
            $table->decimal('total_price',10,2)->default('0')->comment('购买总价格');
            $table->string('out_trade_no')->default('0')->comment('订单号');
            $table->tinyInteger('pay_type')->default('0')->comment('付款方式1微信2余额');
            $table->dateTime('pay_at')->nullable()->comment('付款时间');
            $table->string('transaction_id')->default('')->comment('商户订单号');
            $table->string('payment_no')->default('')->comment('微信交易单号');
            $table->tinyInteger('status')->default('1')->comment('状态(1进行中/2已取消/3已完成)');
            $table->string('comment')->default('')->comment('备注');
            $table->timestamps();
        });
        DB::statement("ALTER TABLE `deal_buyers` comment '买入记录表';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('deal_buyers');
    }
}
